const multer = require('multer');

const storage = multer.diskStorage({
    destination: function (req, file, cb) { //文件存储的位置
        cb(null, './public/images')
    },
    filename: function (req, file, cb) { //设置文件名
        //文件名要根据业务需求。
        let name=file.originalname
        let index=name.lastIndexOf('.');
        cb(null, 'qiyezhanshi_'+name.substring(0,index)+Date.now()+name.substring(index))
    }
})
const upload = multer({ storage: storage });
module.exports=upload;